$('.shopping').hover(function () {
    $('.shopping-box').stop().slideDown(100);
}, function () {
    $('.shopping-box').stop().slideUp(100);
});


$('.select-info>.show-box').mouseenter(function () {
    $('.select-info-box').stop().slideDown(200);
    $('.children').eq($(this).index()-1).show().siblings().hide();
}).mouseleave( function () {
    $('.select-info-box').stop().slideUp(200);
});

$('.select-info-box').hover(function(){
    $(this).stop().slideDown(200);
},function(){
     $(this).stop().slideUp(200);
});


$('.select-input input').focus(function () {
    $(this).css('border', '1px solid #ff6700');
    $('.search').css('border', '1px solid #ff6700').css('border-left', '');
    $('.hot-select').show();
}).blur(function () {
    $(this).css('border', '1px solid #e0e0e0');
    $('.search').css('border', '1px solid #e0e0e0').css('border-left', '');
    $('.hot-select').hide();
});

// --------------------------------------轮播图
var index = 0;

 var timer = setInterval(nextImg,2000);
    function nextImg(){
        index ++;
        if (index == 5) {
            index = 0;
        }
        showImg();
    }
function showImg(){
    $('.banner-img li').eq(index).stop().fadeIn(300).siblings().stop().fadeOut(300);
    $('.indicator li').eq(index).addClass('active').siblings().removeClass('active');
}

$('.banner').mouseenter(function(){
    clearInterval(timer);
}).mouseleave(function(){
     timer = setInterval(nextImg,2000);
});

 $('.indicator li').click(function(){
        index = $(this).index();
        showImg();
});

$('.next').click(function(){
        nextImg();  
    });
    $('.prev').click(function(){
        index --;
        if (index == -1) {
            index = 4;
        }
        showImg(); 
    });
// ------------------------------------------
$('.banner-left>li').hover(function(){
    $(this).children('.banner-select').show();
},function(){
     $(this).children('.banner-select').hide();
});
// ---------------------------------------------
var timer1 = setInterval(autoChangeDP,3000);
var indexDP = 0;
function changeImg(){
    $('.star-info-dp').stop().animate({left:-1226*indexDP},500);
    $('.star-top .more-dp span').eq(indexDP).removeClass('active-star').siblings().addClass('active-star');
}
$('.more-dp .prev').click(function(){
    indexDP = 0;
    changeImg();
});
$('.more-dp .next').click(function(){
    indexDP = 1;
    changeImg();
});

function autoChangeDP() {
    indexDP = indexDP==1 ? 0 : indexDP+1;
    changeImg();
}

 $('.star-top .more-dp span').hover(function(){
     clearInterval(timer1);
     timer1 = null;
 },function(){
     if(timer1)return;
     timer1 = setInterval(autoChangeDP,3000);
 });


// ===================================================================
$('.ul-info li').hover(function(){
    $(this).children('.xia').animate({bottom:0},300);
},function(){
    $(this).children('.xia').animate({bottom:-170},300);
});

$('.box-top li').mouseover(function(){
    $(this).addClass('red').siblings().removeClass('red');
    $(this).parents('.box-top').next('.box-bottom').find('.box-content>ul').eq($(this).index()).addClass('show').siblings().removeClass('show');
});
// ======================内容=======================
var indexNR = 0;
$('.shang').click(function(){
    prev($(this).parents('li').find('.clearfix'));
});
$('.xia').click(function(){
    next($(this).parents('li').find('.clearfix'));
});

function next(content){
    var length = content.find('li').length;
    indexNR = indexNR==length-1 ? length-1 : indexNR+1;
    showNR(content);
}
function prev(content){
     indexNR = indexNR==0 ? 0 : indexNR-1;
     showNR(content);
}
function showNR(content){
    content.stop().animate({left:-296*indexNR},400);
    content.parents('.content').siblings('.yuandian').find('li').eq(indexNR).addClass('yuandian-click').siblings().removeClass('yuandian-click');
}
$('.yuandian li').click(function(){
    indexNR = $(this).index();
    $(this).parents('li').find('.clearfix').stop().animate({left:-296*indexNR},400);
    $(this).addClass('yuandian-click').siblings().removeClass('yuandian-click');
});

$('.box-left4>li').hover(function(){
    $(this).find('.click').children('span').show();
    indexNR = $(this).find('.yuandian .yuandian-click').index();
},function(){
    $(this).find('.click').children('span').hide();
});


// ============================推荐======================================
var indexTJ = 0;
var content1 =  $('.box6').find('.lunbo-ul');
function showTJ(){
    content1.animate({left:indexTJ * - 1226},500);
}
$('.box6 .fa-angle-right').click(function(){
    indexTJ = indexTJ == 3 ? 3 : indexTJ +1;
    if (indexTJ == 3) {
        $(this).removeClass('active-star').siblings().addClass('active-star');
    }
    showTJ();
});
$('.box6 .fa-angle-left').click(function(){
    indexTJ = indexTJ == 0 ? 0 : indexTJ -1;
     if (indexTJ == 0) {
        $(this).removeClass('active-star').siblings().addClass('active-star');
    }
    showTJ();
});
